;;; packages - package definitions for GNU Guix
;;; Copyright (C) 2017 ng0
;;;
;;; This program is free software: you can redistribute it and/or modify
;;; it under the terms of the GNU Affero General Public License as
;;; published by the Free Software Foundation, either version 3 of the
;;; License, or (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU Affero General Public License for more details.
;;;
;;; You should have received a copy of the GNU Affero General Public License
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.

(define-module (ng0 packages networking)
  #:use-module (guix packages)
  #:use-module ((guix licenses) #:prefix license:)
  #:use-module (guix download)
  #:use-module (guix git-download)
  #:use-module (guix build-system gnu)
  #:use-module (gnu packages)
  #:use-module (gnu packages version-control)
  #:use-module (gnu packages gettext)
  #:use-module (gnu packages tls)
  #:use-module (gnu packages xml)
  #:use-module (gnu packages autotools)
  #:use-module (gnu packages m4)
  #:use-module (gnu packages pkg-config))

(define-public cadaver
  (package
    (name "cadaver")
    (version "0.23.3")
    (source
     (origin
       (method url-fetch)
       (uri (string-append "http://www.webdav.org/cadaver/"
                           name "-" version ".tar.gz"))
       (patches (search-patches "cadaver-0.23.2-disable-nls.patch"))
       (sha256
        (base32
         "1jizq69ifrjbjvz5y79wh1ny94gsdby4gdxwjad4bfih6a5fck7x"))))
    (build-system gnu-build-system)
    (arguments
     `(#:configure-flags (list "--disable-nls"
                               "--with-ssl=openssl")
       #:tests? #f))
       ;; #:phases
       ;; (modify-phases %standard-phases
         ;; (add-after 'unpack 'fix-neon-support
         ;;   (lambda _
         ;;     (substitute* "configure.ac"
         ;;       (("27 28 29") "27 28 29 30")
         ;;       (("lib/neon/Makefile") "")
         ;;       (("lib/intl/Makefile") ""))
         ;;     (substitute* "Makefile.in"
         ;;       (("^SUBDIRS.*=.*")
         ;;        "1"))))
         ;; (add-after 'fix-neon-support 'unbundle
         ;;   (lambda _
         ;;     (delete-file-recursively "lib/expat")
         ;;     (delete-file-recursively "lib/neon")
         ;;     (delete-file-recursively "lib/intl")))
         ;; (add-before 'configure 'bootstrap
         ;;   (lambda _
         ;;     (zero? (system* "autoreconf" "-vfi")))))))
    (native-inputs
     `(("gettext" ,gnu-gettext)
       ("automake" ,automake)
       ("autoconf" ,autoconf)
       ("pkg-config" ,pkg-config)
       ("m4" ,m4)))
    (inputs
     `(("neon" ,neon)
       ("expat" ,expat)
       ("openssl" ,openssl)))
    (home-page "http://www.webdav.org/cadaver")
    (synopsis "Command-line WebDAV client")
    (description
     "boredom boredom boredom take me away")
    (license license:gpl2)))

(define-public geomyidae
  (let* ((commit "9a2203506973a803e74ffa80a27f2bf1919b68cc")
         (revision "1"))
  (package
    (name "geomyidae")
    (version (string-append "0.26.3" "-" revision
                            (string-take commit 7)))
    (source
      (origin
        (method git-fetch)
        (uri (git-reference
               (url "git://git.r-36.net/geomyidae")
               (commit commit)))
        (file-name (string-append name "-" version "-checkout"))
        (sha256
          (base32
            "1h79w5340wnqzwsxdlfcchmxrr953fwhbgss4mhjg62x7pdkkvab"))))
    (build-system gnu-build-system)
    (arguments
      `(#:make-flags (list "CC=gcc"
                           (string-append "PREFIX="
                                          (assoc-ref %outputs "out")))
        #:tests? #f
        #:phases
        (modify-phases %standard-phases
          (delete 'configure))))
    (home-page "http://git.r-36.net/geomyidae")
    (synopsis "gopherd server")
    (description
      "Geomyidae is a gopherd for GNU/Linux and BSD.
Its features include:

@enumerate
@item gopher menus (see index.gph for an example)
@item dir listings (if no index.gph was found)
@item cgi support (.cgi files are executed)
@item search support in CGI files
@item logging (-l option) and loglevels (-v option)
@end enumerate\n")
    (license license:x11))))
